/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.fjut.sel1602.csp.service.impl;

import edu.fjut.sel1602.csp.Dao.AccountDao;
import edu.fjut.sel1602.csp.Dao.PetDao;
import edu.fjut.sel1602.csp.Dao.PetOwnerDao;
import edu.fjut.sel1602.csp.Dao.PetStoreDao;
import edu.fjut.sel1602.csp.Dao.impl.AccountDaoImpl;
import edu.fjut.sel1602.csp.Dao.impl.PetDaoOracleImpl;
import edu.fjut.sel1602.csp.Dao.impl.PetOwnerDaoOracleImpl;
import edu.fjut.sel1602.csp.Dao.impl.PetStoreDaoOracleImpl;
import edu.fjut.sel1602.csp.entity.Account;
import edu.fjut.sel1602.csp.entity.Pet;
import edu.fjut.sel1602.csp.entity.PetOwner;
import edu.fjut.sel1602.csp.entity.PetStore;
import edu.fjut.sel1602.csp.service.PetOwnerService;
import edu.fjut.sel1602.csp.service.PetStoreService;
import edu.fjut.sel1602.csp.util.BaseDao;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.List;
import java.util.Scanner;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author lenovo
 */
public class PetStoreServiceImpl implements PetStoreService{

     BaseDao bd=new BaseDao();
    Calendar c=Calendar.getInstance();
    SimpleDateFormat date=new SimpleDateFormat("yyyy-MM-dd");
    PetDao pet =new PetDaoOracleImpl();
    PetOwnerDao owner=new PetOwnerDaoOracleImpl();
    PetStoreDao store=new PetStoreDaoOracleImpl();
    AccountDao account =new AccountDaoImpl();
    PetOwner po=new PetOwner();
    //PetOwnerService pos=new PetOwnerServiceImpl();
    PetStore ps=new PetStore();
    //PetStoreService pss=new PetStoreServiceImpl();
    Scanner input =new Scanner(System.in);
    String dbname=null;
    String dbstorename=null;
    int dbstorepassword=0;
    int dbpassword=0;
    int money;
    int ownerid;
    int petid;
    int price;
    int storeid;
    int balance;
    @Override
    public void buy(Pet pet) {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public void sell(Pet pet) {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

   

    @Override
    public void login() {
        Connection con=BaseDao.getConnection();
        System.out.println("请先登录，输入商店的姓名：");
            String name1=input.next();
            System.out.println("请输入密码：");
            int pwd1=input.nextInt();
            try{
                ResultSet rs=con.createStatement().executeQuery("select *from petstore where NAME='"+name1+"'");
                while(rs.next()){
                    storeid=rs.getInt("ID");
                dbstorename=rs.getString("NAME");
                dbpassword=rs.getInt("PASSWORD");
                balance=rs.getInt("BALANCE");
                }
                if(pwd1==dbpassword){
                 System.out.println("------恭喜您，登录成功！------");
                 System.out.println("---------您的基本信息---------");
                 System.out.println("序号："+storeid);
                 System.out.println("名字："+name1);
                 System.out.println("元宝数："+balance);
                 
                 
            } else
                 System.out.println("商店名字或密码错误");
            }catch (SQLException ex) {
                Logger.getLogger(PetStoreServiceImpl.class.getName()).log(Level.SEVERE, null, ex);
            }  
            BaseDao.closeConnection(con); 
}
    
}
    
    
